
class base;
    function new();
        $display("calling base constructor");
    endfunction
    virtual function void dis();
        $display("base dis"); 
    endfunction
    function void dis_packet();
        dis();
    endfunction
endclass

class derived1 extends base;
    function new();
        $display("calling derived1 constructor");
    endfunction
    virtual function void dis();
        $display("derived1 dis"); 
    endfunction
endclass

// class derived2 extends derived1;
// function new();
//     $display("calling derived2 constructor");
// endfunction
// endclass

// class derived3 extends derived2;
// function new();
//     $display("calling derived3 constructor");
// endfunction
// endclass 

// module testbench; 
// derived3 myderived3;
// initial begin
//     $display("\033[32m\t\t!!\tcode begin\t!!");  
    
//     myderived3=new(); 
//     $display("\t\t!!\tcode end\t!!\033[0m");
//     $finish; 
// end 
// endmodule 


module testbench; 
derived1 myderived1;
initial begin
    $display("\033[32m\t\t!!\tcode begin\t!!");  
    
    myderived1=new(); 
    myderived1.dis_packet();
    $display("\t\t!!\tcode end\t!!\033[0m");
    $finish; 
end 
endmodule 

